import component from "../../../component/Component.js"
import SensorUtils from "../SensorUtils.js";
import { LayerType } from "../../../experience/db/Type.js"

export default class Ventilation extends component {
    constructor() { super() }

    async control() {
        this.ztreeUtil = new SensorUtils();
        this.$$('#equipSelect').hide();
        this.$$('#layerselect-popup').hide();
        this.emitter.on('ventilate-layer-init',() => {
            const staffSource = this.drawer.source(LayerType.SMStaff);
            const broadcastSource = this.drawer.source(LayerType.SMBroadCast);
            const gasSource = this.drawer.source(LayerType.SMGas);

            // 返回的是clustersource的source
            const clusterSource = this.drawer.drawer.SMCluster.getSource().getSource();
            const gasFeatures = gasSource.getFeatures();
            staffSource.clear();
            broadcastSource.clear();
            gasSource.clear();
            clusterSource.clear();

            // 风速，风门传感器
            const windGases = gasFeatures.filter((gas) => {
                const nodeType = gas.get('node_type');
                return nodeType === '风速' || nodeType === '风门';
            });

            windGases.forEach((f) => {
                gasSource.addFeature(f);
                clusterSource.addFeature(f);
            });
        })
    }

    template() {}
}

